<?php
/**
 * --------------------------------------------------------------
 * 数据模型验证器
 * --------------------------------------------------------------
 * Light Year Doc
 * @author yinq<3331653644@qq.com>
 * --------------------------------------------------------------
 */
namespace app\admin\validate;

use think\Validate;

class DataModel extends Validate
{
    // 定义验证规则
    protected $rule = [
        'en_title|模型英文名' => 'require|regex:^[a-z]+[a-z0-9_]{0,39}$|unique:data_model',
        'title|模型名称'      => 'require|length:1,30|unique:data_model',
        'table|附加表'        => 'regex:^[#@a-z]+[a-z0-9#@_]{0,60}$|unique:data_model',
    ];

    // 定义验证提示
    protected $message = [
        'en_title.regex' => '模型英文名由小写字母、数字或下划线组成，不能以数字开头',
        'table.regex'    => '附加表由小写字母、数字或下划线组成，不能以数字开头',
    ];

    // 定义场景
    protected $scene = [
        'edit' =>  ['title'],
    ];
}